<template>
    <view class="wrap">
        <u-form :model="form" ref="uForm">
            <image :src="'../../' + form.nImage" v-if="form.nImage" style="width: 100%;"></image>
            <u-form-item label="选择封面图片" label-position="top">
                <u-input v-model="form.nImage" type="select" @click="images = true" />
                <u-select v-model="images" :list="list" @confirm="selectimg"></u-select>
            </u-form-item>
            <u-form-item label="公告名称" label-position="top"><u-input v-model="form.nTitle" /></u-form-item>
            <u-form-item label="公告内容" label-position="top"><u-input v-model="form.nNotice" type="textarea" /></u-form-item>
        </u-form>
        <view class="u-m-t-20">
            <u-row gutter="16" justify="center">
                <u-col span="10"><u-button type="primary" @click="saveData()" :ripple="true">保存</u-button></u-col>
            </u-row>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            form: {},
            images: false,
            list: [
                { value: 'static/list/list_1.png', label: '1' },
                { value: 'static/list/list_2.png', label: '2' },
                { value: 'static/list/list_3.png', label: '3' },
                { value: 'static/list/list_4.png', label: '4' },
                { value: 'static/list/list_5.png', label: '5' },
                { value: 'static/list/list_6.png', label: '6' },
                { value: 'static/list/list_7.png', label: '7' },
                { value: 'static/list/list_8.png', label: '8' },
                { value: 'static/list/list_9.png', label: '9' }
            ]
        }
    },
    onLoad(opt) {
        this.info = JSON.parse(opt.p)
        if (this.info) {
            this.form = this.info
        }
    },
    methods: {
        selectimg(e) {
            this.form.nImage = e[0].value
        },
        saveData() {
            this.$u.post('/apps/ssNoticeEntity', this.form).then(res => {
                if (res && res.code == 200) {
                    this.$u.route({
                        type: 'switchTab',
                        url: 'pages/notice/notice_list'
                    })
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
.wrap {
    padding: 24rpx;
}
.wrap1 {
    padding: 13rpx;
}
.ll {
    margin-right: 10rpx;
    margin-bottom: 4rpx;
}
</style>
